<%@ page language="java" pageEncoding="UTF-8"%>
<%@ page import="com.meritit.portal.util.PageAction"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html xmlns="http://www.w3.org/1999/xhtml" >
	<head>
		<title>单点业务系统管理</title>
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/skins/home.css" />
		<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/ymPrompt/skin/qq/ymPrompt.css" />
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/ymPrompt/ymPrompt.js"></script>
		<script type="text/javascript" src="${pageContext.request.contextPath}/js/jquery-1.6.4.min.js"></script>
	</head>
	<body style="margin:0px;padding:0px;">
		<form name="myForm" id="myForm" action="${pageContext.request.contextPath}/ssoSystem/ssoSystemMgr?userId=${userId}"
			method="post">
			<!-- portal begin -->
			<div class="pt-pt pt-chg-Gray"  style="overflow:hidden;">
				<div class="g-btns margin-t-10 align-r">
					<span class="g-big-btn">
						<a class="g-big-btn-inner" href="javascript:add();"title="新增数据">
							<b>新增</b>
							<b class="g-big-btn-rc g-big-btn-rc-1"></b>
							<b class="g-big-btn-rc g-big-btn-rc-2"></b>
						</a>
					</span>
					<span class="g-big-btn">
						<a class="g-big-btn-inner" title="删除选中数据后将不可恢复" href="javascript:delBatch();">
							<b>删除</b>
							<b class="g-big-btn-rc g-big-btn-rc-1"></b>
							<b class="g-big-btn-rc g-big-btn-rc-2"></b>
						</a>
					</span>
				</div>
				<div class="pt-pt-tit"><table class="p-p-t-ent"><tr>
					<td class="p-p-t-ent-l"><i>&nbsp;</i></td>
					<td class="p-p-t-ent-c">
						<div class="p-p-t-13-d">
							<span class="p-p-t-t">单点业务系统管理</span>
						</div>
					</td>
					<td class="p-p-t-ent-r"><i>&nbsp;</i></td>
				</tr></table></div>
				<div class="pt-pt-cont">
					<table class="p-table" id="listTable" >
						<thead>
							<tr style="font-family:\5b8b\4f53;font-size:12px;">
								<td title="全选">
									<input type="checkbox" id="selectAll" onclick="selectAllDatas(this)" />
								</td>
								<td>
									系统简称
								</td>
								<td>
									系统编码
								</td>
								<td>
									登录URL
								</td>
								<td>
									是否启用常用业务
								</td>
								<td>
									是否是公开业务系统
								</td>
								<td>
									是否显示
								</td>
								<td>
									操作
								</td>
							</tr>
						</thead>
						<tbody>
							<s:iterator id="list" value="#request.syslist.list" status="st">
								<tr style="font-family:\5b8b\4f53;font-size:12px;" class="<s:if test="#st.odd">odd</s:if><s:else>even</s:else>">
									<td>
										<input id="beId" name="beId" type="checkbox" value='<s:property value="id" />' onclick="changeSelectAll(this)" />
									</td>
									<td id='sys_<s:property value="id" />'>
										<s:property value="shortName" />
									</td>
									<td>
										<s:property value="code" />
									</td>
									<td title="<s:property value="loginUrl" />">
										<s:property value="@com.meritit.portal.util.CustomerFormatter@format(loginUrl, 25)" />
									</td>
									<td>
										<s:property value="cbWsEnable" />
									</td>
									<td>
										<s:property value="isPublic" />
									</td>
									<td>
										<s:property value="isShow" />
									</td>
									<td style="width: 80px;">
										<a  onclick="update('<s:property value="id" />')"  title="修改">修改</a>
										<a  onclick="del('<s:property value="id" />')"  title="删除">删除</a>
									</td>
								</tr>
							</s:iterator>
						</tbody>
					</table>
					<div class="list-pageNav">
						<INPUT TYPE="hidden" id="currentPage" name="currentPage" value="${syslist.currentPage}">
						<INPUT TYPE="hidden" id="totalPage" name="totalPage" value="${syslist.totalPages}">
						<INPUT TYPE="hidden" id="pageAction" name="pageAction" value="">
						<span class="pageNav-info">第<b>${syslist.currentPage}/${syslist.totalPages}</b>页&nbsp;&nbsp;共<b>${syslist.totalItem}</b>条记录</span>
						<span class="pageNav-page">
							<a  onclick="goPage('<%=PageAction.FIRST.toString()%>')"  title="首页">首页</a>|
							<a  onclick="goPage('<%=PageAction.PREVIOUS.toString()%>')"  title="上页">上页</a>|
							<a  onclick="goPage('<%=PageAction.NEXT.toString()%>')"  title="下页">下页</a>|
							<a  onclick="goPage('<%=PageAction.LAST.toString()%>')" title="末页">末页</a>
							<span class="jumpPage">转到第
								<input type="text" id="jumpPage" name="jumpPage" title="目标页码" />
								<button onclick="jump2Page('<%=PageAction.JUMP.toString()%>')" class="jump_btn"></button>
							</span>
						</span>
					</div>
				</div>
				<div class="pt-pt-bt-corner">
					<b class="pt-pt-bt-cor-l">&nbsp;</b>
					<b class="pt-pt-bt-cor-r">&nbsp;</b>
				</div>
			</div>
		</form>
	</body>
	<script type="text/javascript">
		function openWin(id_, url, width, height){
		    window.open(url, id_, 'left=' + (screen.availWidth - width)/2 + 
		    	', top=' + (screen.availHeight - height)/2 + 
		    	', width=' + width + ', height=' + height + 
		    	', scrollbars=yes, resizable=yes, location=no, status=yes');
		}
		
		/**全选*/
		function selectAllDatas(obj) {
			var boxes = $(':checkbox[id!="selectAll"]');
			var length = boxes.length;
			for (var i = 0; i < length; i ++) {
				boxes[i].checked = obj.checked;
			}
		}
		
		/**修改全选状态*/
		function changeSelectAll(obj) {
			var checked = obj.checked;
			if (checked) {
				var boxes = $(':checkbox[id!="selectAll"]');
				var length = boxes.length;
				for (var i = 0; i < length; i ++) {
					if (!boxes[i].checked) {
						checked = false;
						break;
					}
				}
			}
			$('#selectAll').attr('checked', checked);
		}
		
		/**新增*/
		function add() {
			var url = '${pageContext.request.contextPath}/ssoSystem/ssoSystemMgr!preAdd?userId=${userId}';
			openWin('addSsoSystem', url, 800, 530);
		}
		
		/**修改*/
		function update(id) {
			var url = '${pageContext.request.contextPath}/ssoSystem/ssoSystemMgr!preUpdate?userId=${userId}&id=' + id;
			openWin('updateSsoSystem', url, 800, 530);
		}
		
		/**删除*/
		function del(id) {
			ymPrompt.confirmInfo({
				message: '系统将删除所有与选中项关联的数据信息，您确定要进行删除操作吗？',
     			width: 320,
     			maskAlpha: 0,
				maskAlpha: 0,
				handler: function handle(tp) {
					if (tp == 'ok') {
						$.ajax({
			         		url: '${pageContext.request.contextPath}/ssoSystem/ssoSystemMgr!del?userId=${userId}&id=' + id, 
			         		type: 'post',
			         		dataType: 'text', 
			         		success: function (data) { 
				         		if (data == 'ok') {
					         		ymPrompt.succeedInfo({
					         			message: '操作成功',
					         			width: 300,
					         			height: 200,
					         			maskAlpha: 0,
					         			handler: function hand1() {
					         				savelog(id);
					         				window.location.href = window.location.href;
					         			}
					         		});
					         	} else {
					         		ymPrompt.errorInfo({
					         			message: '操作失败,可能原因：该记录已经被其他数据引用，请检查业务数据管理或常用业务定制或业务入口定制。如果您不需要该数据显示，推荐您修改是否显示标志位为N!',
					         			width: 320,
					         			maskAlpha: 0,
					         			height: 200
				         			});
					         	}
				         	}
			      		});
					}
				}
			});
		}
		
		/**批量删除*/
		function delBatch(id) {
			ymPrompt.confirmInfo({
				message: '系统将删除所有与选中项关联的数据信息，您确定要进行删除操作吗？',
     			width: 320,
     			maskAlpha: 0,
				maskAlpha: 0,
				handler: function handle(tp) {
					if (tp == 'ok') {
						var id = getIds();
						if (id.length == 0) {
							ymPrompt.alert({
								title: '提示信息',
								maskAlpha: 0,
								message: "您还未进行选择！"
							});
						} else {
							$.ajax({
				         		url: '${pageContext.request.contextPath}/ssoSystem/ssoSystemMgr!del?userId=${userId}&id=' + id, 
				         		type: 'post',
				         		dataType: 'text', 
				         		success: function (data) { 
					         		if (data == 'ok') {
						         		ymPrompt.succeedInfo({
						         			message: '操作成功',
						         			width: 300,
						         			height: 200,
						         			maskAlpha: 0,
						         			handler: function hand1() {
						         				savelog(id);
						         				window.location.href = window.location.href;
						         			}
						         		});
						         	} else {
						         		ymPrompt.errorInfo({
						         			message: '操作失败,可能原因：该记录已经被其他数据引用，请检查业务数据管理或常用业务定制或业务入口定制。如果您不需要该数据显示，推荐您修改是否显示标志位为N!',
						         			width: 320,
						         			maskAlpha: 0,
						         			height: 200
					         			});
						         	}
					         	}
				      		});
						}
					}
				}
			});
		}
		
		function getIds(){
			var ids = "";
			var checkObj = $("input[name='beId']");
			for (var i = 0; i < checkObj.length; i ++) {
				if (checkObj[i].checked) {
					ids += checkObj[i].value + ";";
				}
			}
			return ids;
		}
		
		/**添加日志*/
		function getSys(ids){
		    var res = '';
			var id = ids.split(';');
			for (var i = 0; i < id.length; i ++) {
				if (id[i] != null && id[i] != '' && id[i] != 'undefined') {
				    var tds = document.getElementById("sys_" + id[i]);
			    	res += tds.innerHTML + ' ';
				}
			}
		    return res;
		}
		
		function savelog(id){
			var info = "删除@删除了业务系统【" + getSys(id) + "】信息";
		    $.ajax({
		         url: '${pageContext.request.contextPath}/operLog/addLog!addMgrLog?userId=${userId}&info=' + encodeURI(info, 'UTF-8'), 
		         type: 'post',
		         dataType: 'text', 
		         success:function(data){}
		    });
		}
		/**分页*/
		var listForm = document.getElementById("myForm");
		function goPage(pageAction){
		    var pageActionObj = document.getElementById("pageAction");
		    var currentPage = document.getElementById("currentPage");
		    var totalPage = document.getElementById("totalPage");
		    alert(listForm);
		    if(pageAction=="FIRST" || pageAction=="PREVIOUS"){
		        if(parseInt(currentPage.value) == 1){
		           ymPrompt.alert({title:'提示信息',maskAlpha:0,message:'已经是第一页了!'});
		           return ;
		        }else{
		            pageActionObj.value=pageAction;
					if(listForm != null){
					   listForm.submit();
					}
					listForm = null;
					return ;
		        }
		    }else if(pageAction == "LAST" || pageAction=="NEXT"){
		        if(parseInt(currentPage.value)==parseInt(totalPage.value)){
		            ymPrompt.alert({title:'提示信息',maskAlpha:0,message:'您已经在最后一页了！'});
		            return ;
		        }else{
		            pageActionObj.value=pageAction;
					if(listForm != null){
					   listForm.submit();
					}
					listForm = null;
					return ;
		        }
		    }
		}
		/**跳页*/
		function jump2Page(pageAction){
		    var pageActionObj = document.getElementById("pageAction");
		    var jumpPage = document.getElementById("jumpPage");
		    var currentPage = document.getElementById("currentPage");
		    var totalPage = document.getElementById("totalPage");
		    var re=new RegExp("[0-9]");
		    var tt=parseInt(jumpPage.value);
		     if(!re.test(jumpPage.value)){
				ymPrompt.alert({title:'提示信息',maskAlpha:0,message:'请输入合理整数！'});
				return;
			}
			if(tt<=0){
				ymPrompt.alert({title:'提示信息',maskAlpha:0,message:'您要去的第'+tt+'页并不存在！'});
				return;
			}
		 	if(tt>parseInt(totalPage.value)){
		 		ymPrompt.alert({title:'提示信息',maskAlpha:0,message:"共有"+totalPage.value+"页,您要去的第"+tt+"页并不存在！"});
				return;
		    }
	        pageActionObj.value=pageAction;
			if(listForm != null){
			   listForm.submit();
		    }
		    listForm = null;
		    return ;
		}
		
		function stop(){
			return false;
		}
		document.oncontextmenu = stop;
	</script>
</html>